<template>
  <van-swipe-cell :right-width="50">
    <van-cell-group>
      <view class="MyTaskList animate__animated animate__bounceInRight">
        <view class="title">{{ taskListDetail.title }}</view>
        <view class="taskNumber"
          >当前拥有任务数量：{{ taskListDetail.tasks.length }} 个
        </view>
        <view class="time"
          >创建时间：{{
            $formatTime.formatTimeToHHMMSS(taskListDetail.createTime)
          }}</view
        >
        <view
          class="tipTag"
          style="background: #05a47d"
          v-if="taskListDetail.isTeam"
          >队伍</view
        >
      </view>
    </van-cell-group>
    <view slot="right">
      <view class="rightBox" @click="handleDeleteTaskList" style="width: 100rpx"
        >删除</view
      >
    </view>
  </van-swipe-cell>
</template>

<script>
export default {
  name: "MyTaskList",
  props: {
    taskListDetail: {
      type: Object,
      required: true,
    },
  },
  methods: {
    // 删除任务列表
    async handleDeleteTaskList() {
      const listId = this.taskListDetail._id,
        taskList = this.taskListDetail.tasks,
        isTeam = this.taskListDetail.isTeam;
      try {
        await this.$store.dispatch("m_task/deleteTaskList", {
          listId,
          taskList,
          isTeam,
        });
        this.$emit("refreshTaskList");
        uni.showToast({
          icon: "success",
          title: "删除成功",
        });
      } catch (err) {
        console.log("删除失败：", err);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.MyTaskList {
  position: relative;
  padding: 10rpx;
  height: 140rpx;
  overflow: hidden;
  background-color: #fff;
  color: #999;
  font-size: 28rpx;
  margin-bottom: 10rpx;
  .title { 
    font-size: 36rpx;
    font-weight: 500;
    color: #000;
    margin-bottom: 10rpx;
  }
  .tipTag {
    position: absolute;
    box-sizing: border-box;
    width: 200rpx;
    display: flex;
    justify-content: center;
    align-content: center;
    padding: 10rpx 20rpx;
    color: #fff;
    right: -50rpx;
    top: 20rpx;
    font-size: 26rpx;
    transform: rotate(45deg);
  }
}
.rightBox {
  line-height: 160rpx;
  height: 160rpx;
  text-align: center;
  font-size: 30rpx;
  background-color: #aaa;
  color: #fff;
}
</style>
